package com.cn.main.web;

import com.cn.main.config.MyConfig;
import com.cn.main.config.MyConfigMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/**
 * Created by chenyuncong on 2018/5/21.
 */
@RestController
@RequestMapping("test")
public class TestController {

    @Value("${config.my.name}")
    private String name;
    @Value("${config.my.sex}")
    private String sex;

    @Autowired
    private MyConfig myConfig;
    @Autowired
    private MyConfigMap myConfigMap;

    @RequestMapping("getInfo")
    public Map<String,Object> getInfo(){
        Map<String,Object> map=new HashMap<>();
        map.put("name",name);
        map.put("sex",sex);
        return map;
    }

    @RequestMapping("getMyConfig")
    public MyConfig getMyConfig(){
        return myConfig;
    }

    @RequestMapping("getMyConfigMap")
    public Map<String,String> getMyConfigMap(){
        Map<String,String> map=myConfigMap.getMy();
        return map;
    }

}
